#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int gcd(int a, int b)
{
	return b == 0 ? a : gcd(b, a % b);
}

int main()
{
	LL m, n; cin >> m >> n;
	m ++, n ++;
	LL t = n * m;
	LL ans = t * (t - 1) * (t - 2) / 6;
	ans -= m * n * (n - 1) * (n - 2) / 6;
	ans -= m * n * (m - 1) * (m - 2) / 6;
	for(int i = 1;i <= m;i ++)
		for(int j = 1;j <= n;j ++)
			ans -= 2 * (m - i) * (n - j) * (gcd(i, j) - 1);
	cout << ans << endl;

	return 0;
}